package com.qinggeng.project.system.controller;

import com.qinggeng.common.utils.poi.ExcelUtil;
import com.qinggeng.framework.aspectj.lang.annotation.Log;
import com.qinggeng.framework.aspectj.lang.enums.BusinessType;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.framework.web.page.TableDataInfo;
import com.qinggeng.project.system.domain.AssistHelp;
import com.qinggeng.project.system.service.IAssistHelpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 帮助力Controller
 * 
 * @author ruoyi
 * @date 2020-11-09
 */
@RestController
@RequestMapping("/system/help")
public class AssistHelpController extends BaseController
{
    @Autowired
    private IAssistHelpService assistHelpService;

    /**
     * 查询帮助力列表
     */
    @PreAuthorize("@ss.hasPermi('system:help:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssistHelp assistHelp)
    {
        startPage();
        List<AssistHelp> list = assistHelpService.selectAssistHelpList(assistHelp);
        return getDataTable(list);
    }

    /**
     * 导出帮助力列表
     */
    @PreAuthorize("@ss.hasPermi('system:help:export')")
    @Log(title = "帮助力", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AssistHelp assistHelp)
    {
        List<AssistHelp> list = assistHelpService.selectAssistHelpList(assistHelp);
        ExcelUtil<AssistHelp> util = new ExcelUtil<AssistHelp>(AssistHelp.class);
        return util.exportExcel(list, "help");
    }

    /**
     * 获取帮助力详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:help:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(assistHelpService.selectAssistHelpById(id));
    }

    /**
     * 新增帮助力
     */
    @PreAuthorize("@ss.hasPermi('system:help:add')")
    @Log(title = "帮助力", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssistHelp assistHelp)
    {
        return toAjax(assistHelpService.insertAssistHelp(assistHelp));
    }

    /**
     * 修改帮助力
     */
    @PreAuthorize("@ss.hasPermi('system:help:edit')")
    @Log(title = "帮助力", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssistHelp assistHelp)
    {
        return toAjax(assistHelpService.updateAssistHelp(assistHelp));
    }

    /**
     * 删除帮助力
     */
    @PreAuthorize("@ss.hasPermi('system:help:remove')")
    @Log(title = "帮助力", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assistHelpService.deleteAssistHelpByIds(ids));
    }
}
